package world;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class Player {

	static Animation movingUp, movingDown, movingLeft, movingRight;
	static Animation temp;
	static float x;
	static float y;
	static Event event;
	int[] duration = {200, 200};
	
	public Player(Event event) throws SlickException{
		
		
		Image[] walkUp = {new Image("res/world/buckysBack.png"), new Image("res/world/buckysFront.png")};
		Image[] walkDown = {new Image("res/world/buckysFront.png"), new Image("res/world/buckysFront.png")};
		Image[] walkLeft = {new Image("res/world/buckysLeft.png"), new Image("res/world/buckysLeft.png")};
		Image[] walkRight = {new Image("res/world/buckysRight.png"), new Image("res/world/buckysRight.png")};
		
		movingUp = new Animation(walkUp, duration, false);
		movingDown = new Animation(walkDown, duration, false);
		movingLeft = new Animation(walkLeft, duration, false);
		movingRight = new Animation(walkRight, duration, false);

		changeAni(1);
	    Player.event = event;
		x = event.getX();
		y = event.getY();
		
	
		
	}

	public static void renderPlayer(float tokenPositionX, float tokenPositionY) {
		
		int height = temp.getHeight();
		int width = temp.getWidth();
		
		temp.draw((tokenPositionX + x) - (width/2), (tokenPositionY + y) - (height/2));
		
	}

public  static void  setX(float x){Player.x = x;}
public static void  setY(float y){Player.y = y;}	
	
 public static void setEvent(Event event){
	 
	 Player.event = event;
	 x = event.getX();
	 y = event.getY();
	 
	 
	System.out.println("Player arrived at " + event.getName()); 
	 
	 
 }
 
 public Event getEvent(){return event;}
 
 public float getX(){return x;}
 
 public float getY(){return y;}
 
 
 public static void changeAni(int change){
	 
	 switch(change){
	 
	 case 0: temp = movingUp;
		 break;
	 case 1: temp = movingDown;
		 break;
	 case 2: temp = movingLeft;
		 break;
	 case 3: temp = movingRight;
	
	 }
	 
	 
	 
	 
 }
 
 public Animation getImage(){return temp;}
 
}

 